package com.jj.fly.utils;

import java.util.UUID;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 生成token随机码
 * 
 * @author JJ
 *
 */
@Component
public class TokenUtils {

	@Autowired
	private HttpSession session;

	/**
	 * 生成token随机码
	 * 
	 * @return
	 */
	public synchronized String generateTokenCode() {
		String token = UUID.randomUUID().toString();
		session.setAttribute("token", token); // 将token随机码保存到session中
		return token;
	}
}
